<!--
@license
Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../../../tf-imports/polymer.html">
<link rel="import" href="../../../iron-list/iron-list.html">
<link rel="import" href="../../../paper-button/paper-button.html">
<link rel="import" href="../../../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../../../tf-imports/plottable.html">
<link rel="import" href="../../common/common_bundle.html">

<dom-module id='facets-overview-chart'>
  <template>
    <style include="plottable-style"></style>
    <style>
      .plottable.chart-small {
        height: 46px;
        width: 250px;
      }
      .plottable.xaxis-small{
        height: 30px;
        width: 250px;
      }
      .plottable.chart-big {
        height: 200px;
        width: 550px;
      }
      .plottable.xaxis-big {
        height: 50px;
        width: 550px;
      }
      #show_table_button {
        margin: 0 0 0 5px;
        padding: 0 3px;
        font-size: 7pt;
        background-color: #d3d3d3;
      }
      .dialog-row-entry {
        padding: 0 10px 0 0;
      }
      .table-header {
        border-bottom: 1px solid black;
      }
      .dialog-row, .dialog-header-row {
        display: flex;
      }
      .dialog-row.selected {
        border: 1px solid black
      }
      .dialog-row:hover {
        background-color: #D0D0D0;
        cursor: pointer;
      }
      .dialog-table {
        clear: left;
      }
      .label-cell {
        width: 90px;
        max-width: 90px;
        min-width: 90px;
        overflow-wrap: break-word;
      }
      .non-overflow-label-cell {
        width: 90px;
        max-width: 90px;
        min-width: 90px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .count-cell {
        width: 100px;
        max-width: 100px;
        min-width: 100px;
        overflow-wrap: break-word;
      }
      .weighted-cell {
        font-style: italic;
      }
      .data-list-small {
        height: 60px;
      }
      .data-list-big {
        height: 180px;
        width: 550px;
      }
      .hidechart {
        display: none;
      }
      .showchart {
        display: inline;
      }
      #tooltip {
        background-color: var(--paper-tooltip-background, #616161);
        opacity: 0;
        color: white;
        pointer-events:none;
        transition: opacity 0.3s;
        position: absolute;
        text-align:center;
        padding: 6px;
        border-radius: 2px;
        font-size: 12px;
        line-height: 1;
        margin-left: 50px;
        white-space: pre;
        top: 0px;
      }
      .toplevel {
        position: relative;
        text-align: left;
        padding-top: 4px;
      }
    </style>
    <div class="toplevel">
      <template is="dom-if" if="[[_isStringChart(_chartType, chartSelection)]]">
        <paper-button id="show_table_button" on-click="_toggleShowTable">[[_getShowTableButtonText(_showTable)]]</paper-button>
      </template>
      <div class$="[[_chartClass]]">
        <div id="chart" class$="[[_chartSvgClass]]"></div>
        <div id="xaxis" class$="[[_xAxisSvgClass]]"></div>
      </div>
      <template is="dom-if" if="[[_showTable]]">
        <div class="dialog-table">
          <div class="dialog-header-row">
            <div class="dialog-row-entry table-header label-cell">Value</div>
            <template is="dom-repeat" items="[[data]]" as="data">
              <div class="dialog-row-entry table-header">
                <div class="non-overflow-label-cell">[[data.name]]</div>
              </div>
            </template>
          </div>
          <iron-list items="[[_tableData]]" as="entry" class$="[[_tableDataClass]]">
            <template>
              <div class$="[[_getEntryRowClass(entry, selection)]]" on-tap="_rowClick" data-value="[[_getEntryRowValue(entry)]]">
                <div class="dialog-row-entry label-cell">[[entry.value]]</div>
                <template is="dom-repeat" items="[[entry.counts]]" as="count">
                  <div class$="[[_getCountCellClass(showWeighted)]]">[[count]]</div>
                </template>
              </div>
            </template>
          </iron-list>
        </div>
      </template>
      <div id="tooltip"></div>
    </div>
  </template>
</dom-module>
<script src="facets-overview-chart.js"></script>
